import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        redirect: '/index'
    },
    {
        path: '/index',
        name: 'Index',
        component: () => import( '../views/Index.vue'),
    },
    {
        path: '/login-register',
        name: 'LoginRegister',
        component: () => import( '../views/user/LoginAndRegister.vue'),
        redirect: '/login-register/login',
        children: [
            {
                path: 'login',
                name: 'Login',
                component: () => import( '../views/user/Login.vue'),
            },
            {
                path: 'register',
                name: 'Register',
                component: () => import( '../views/user/Register.vue'),
            }
        ]
    },
    {
        path: '/user-center',
        name: 'UserCenter',
        component: () => import( '../views/user/UserCenter.vue'),
        redirect: '/user-center/user-info',
        children: [
            {
                path: 'user-info',
                name: 'UserInfo',
                component: () => import( '../views/user/UserInfo.vue'),
            },
            {
                path: 'agent-info',
                name: 'AgentInfo',
                component: () => import( '../views/user/AgentInfo.vue'),
            },
            {
                path: 'my-property',
                name: 'MyProperty',
                component: () => import( '../views/user/MyProperty.vue'),
            }
        ]
    },
    {
        path: '/add-property',
        name: 'AddProperty',
        component: () => import( '../views/property/AddProperty.vue'),
    },
    {
        path: '/property-list',
        name: 'PropertyList',
        component: () => import( '../views/property/PropertyList.vue'),
    },
    {
        path: '/property-detail',
        name: 'PropertyDetail',
        component: () => import( '../views/property/PropertyDetail.vue'),
    }
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
});

export default router
